<template>
    <el-form :model="form" label-width="auto" style="max-width: 600px">
      <el-form-item label="联系方式">
        <el-input v-model="form.phone" />
      </el-form-item>
      <el-form-item label="家庭地址">
        <el-input v-model="form.address" />
      </el-form-item>
      <el-form-item label="性别">
      <el-radio-group v-model="form.sex">
        <el-radio value="Sponsor">男</el-radio>
        <el-radio value="Venue">女</el-radio>
      </el-radio-group>
    </el-form-item>

      <el-form-item>
        <el-button type="primary" @click="onSubmit">完善</el-button>
        <el-button>重置</el-button>
      </el-form-item>
    </el-form>
  </template>
  
  <script lang="ts" setup>
  import { reactive } from 'vue'
  import { perfectInfo } from '../../api/service.js'
import { ElMessage } from 'element-plus';
  
  // do not use same name with ref
  const form = reactive({
    phone: '',
    address: '',
    sex: '',
  })
  
  const onSubmit = async() => {
    try{
      const result = await perfectInfo(form);
      if(result.data.code === 200){
        ElMessage.success('信息完善成功')
      }else{
        ElMessage.error('信息完善失败')
      }
    }catch(error){
      ElMessage.error('信息完善失败')
    }
  }
  </script>
  